-
Notifications
You must be signed in to change notification settings - Fork 421
OCPBUGS-65925: Fall back to simpler behavior, if setsid,ps,pkill are not installed #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@ardaguclu: This pull request references Jira Issue OCPBUGS-65925, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughRuntime detection for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**⚙️ CodeRabbit configuration file
Files:
🔇 Additional comments (1)
Comment |
|
I got this PR #2152 into this PR. |
|
/cc @tchap could you PTAL?. |
|
/jira refresh |
|
@ardaguclu: This pull request references Jira Issue OCPBUGS-65925, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
0dc285a to
1f93007
Compare
|
Read it as thoroughly as I managed, looks principally ok. If we wanted to be super pretty, we could do /lgtm |
Thank you. So next step would have a pre-merge tests. |
|
Note that #2152 is unfinished and the change does not fix anything yet. But no problem with merging it, I guess. |
Why do you think that?. The ask is to printing this message to stderr and this achieves this. What am I missing? |
We are streaming pod logs, right? So there are two separate steps involved:
While the first is trivial, the latter is not and it seems the relevant functionality is behind an alpha feature gate We cannot even implement this currently, I guess. |
Thanks. That makes sense. So I think, we can close the bug. Because it sounds like a feature request. I'd prefer reverting that feature from this PR as well. |
1f93007 to
4a34714
Compare
|
It might be more of a feature request. /lgtm |
That is correct. However, if we rely on a feature on upstream, I think this can be considered as a feature. |
|
/retest |
|
/hold cancel |
|
/label qe-approved |
|
@ardaguclu: This pull request references Jira Issue OCPBUGS-65925, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/verified by @zhouying7780 and @ardaguclu |
|
@ardaguclu: This PR has been marked as verified by In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/hold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
pkg/cli/admin/mustgather/mustgather.go(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
pkg/cli/admin/mustgather/mustgather.go
🔇 Additional comments (1)
pkg/cli/admin/mustgather/mustgather.go (1)
1332-1345: LGTM! The fallback logic is well-implemented.The runtime check correctly handles both scenarios:
- When
setsid,ps, andpkillare available, the gather command runs in a separate session as intended.- When these utilities are missing, the gather command runs directly, which is a reasonable fallback for minimal images.
The subsequent
syncensures data is flushed to disk after gathering completes.
| if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then | ||
| ps -o sess --no-headers | sort -u | while read sid; do | ||
| [[ "$sid" -eq "${$}" ]] && continue | ||
| pkill --signal SIGKILL --session "$sid" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax and logic error in session comparison.
Line 104 has two critical issues:
- Syntax error:
${$}is invalid bash syntax. The standard way to reference the current PID is$$(without braces). - Logic error: The code compares a session ID (
$sid) with a process ID (${$}), which are different values. To correctly skip the current session, you must compare session IDs.
Apply this diff to fix both issues:
if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then
+ current_sid=$(ps -o sess= -p $$)
ps -o sess --no-headers | sort -u | while read sid; do
- [[ "$sid" -eq "${$}" ]] && continue
+ [[ "$sid" -eq "$current_sid" ]] && continue
pkill --signal SIGKILL --session "$sid"
done📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then | |
| ps -o sess --no-headers | sort -u | while read sid; do | |
| [[ "$sid" -eq "${$}" ]] && continue | |
| pkill --signal SIGKILL --session "$sid" | |
| done | |
| if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then | |
| current_sid=$(ps -o sess= -p $$) | |
| ps -o sess --no-headers | sort -u | while read sid; do | |
| [[ "$sid" -eq "$current_sid" ]] && continue | |
| pkill --signal SIGKILL --session "$sid" | |
| done |
🤖 Prompt for AI Agents
In pkg/cli/admin/mustgather/mustgather.go around lines 102 to 106, fix the
invalid bash syntax `${$}` and the incorrect comparison between a session ID and
the current process ID: determine the current session ID (e.g., via `ps -o sess=
-p $$`) into a variable (current_sid) and then compare `"$sid"` to
`"$current_sid"` to skip killing the current session; replace the `${$}` usage
with that current_sid variable and keep the rest of the pkill logic unchanged.
d8d5647 to
6aae67e
Compare
|
/hold cancel |
| [[ "$sid" -eq "${$}" ]] && continue | ||
| pkill --signal SIGKILL --session "$sid" | ||
| done | ||
| if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would honestly just set a helper variable initially and then use it everywhere. This is getting ugly. Like, set a variable to non-empty value if we can do sessions, and do that at the beginning of buildPodCommand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to any suggestions as long as we can inject this helper variable from buildPodCommand to volumeCheckerScript. Would you please elaborate your exact suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that everything is just concatenated in buildPodCommand, so isn't any variable visible later on? Perhaps you need to export it for the subshells to make it work...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, when I tested this, subshells did not see the variables in the main session. Claude suggested me exporting this variable and I rejected the suggestion. But I'll retry exporting this environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a mistake about ordering. So that's why variable didn't work previously. This works now. Could you PTAL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, thanks!
|
/hold |
566e167 to
201abbf
Compare
|
/hold cancel |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ardaguclu, tchap The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
@ardaguclu: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
setsidbrings us robust session killing, when volumesizechecker detects any exceeded volume usage. This works well in default must-gather image as well as others thatsetsidis installed.However, there are some images that
setsidis not installed. This method does not work and more importantly must-gather does not work. So we must introduce a fall back approach for the images that lack such binaries.This PR checks the presence of
setsid. If it is present, it will continue using the current approach. If it is not, it will run the scripts in simpler way. If volumesize checker detects the exceeded volume usage, it will runkill 0to kill every process. We can't provide elegant options because these images do not include any binaries that we can use such asps,setsid, etc.